import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { BaseAdminResult, BaseResult, BaseScrollPageListResult } from "@/common/base/base.result";
import {
  ArticleNormalCategory,
  ArticleStatus,
  ArticleType,
  BooleanNumber,
  UserTitleCertification,
} from 'common/utils/data';

class ArticleIndexBaseResult extends BaseScrollPageListResult{
  @ApiProperty()
  title: string;

  @ApiProperty()
  desc: string;

  @ApiProperty()
  descByContent: string;

  @ApiProperty()
  commentCount: number

  @ApiProperty()
  keywords: string[]

  @ApiProperty()
  publishTime: number

  @ApiProperty()
  thumbnails: string[]

  @ApiProperty()
  thumbnailsByContent: string[]
}
export class ArticleIndexNormalUser extends BaseResult{
  @ApiProperty()
  avatar: string;

  @ApiProperty()
  name: string;

  @ApiProperty()
  titleCertification: string;
}

export class ArticleIndexNormalResult extends ArticleIndexBaseResult {
  @ApiProperty()
  user: ArticleIndexNormalUser
}

export class ArticleIndexMineResult extends BaseScrollPageListResult {
  @ApiProperty({
    description: '标题',
  })
  title: string;

  @ApiProperty({
    description: '状态',
    enum: ArticleStatus,
  })
  status: ArticleStatus;

  @ApiProperty({
    description: '是否置顶',
  })
  isStick: BooleanNumber;

  @ApiProperty()
  categories: ArticleNormalCategory[];
}

class ArticleExt {
  @ApiProperty()
  content: string;

  @ApiProperty()
  contentRaw: string;
}

export class ArticleShowMineResult extends ArticleIndexNormalResult {
  @ApiProperty({
    enum: ArticleStatus,
  })
  status: ArticleStatus;

  @ApiProperty()
  ext: ArticleExt;

  @ApiProperty()
  categories: ArticleNormalCategory[];
}

export class ArticleCreateResult extends BaseResult {
}

class ArticleUser {
  @ApiProperty()
  uuid: string;

  @ApiProperty()
  avatar: string;

  @ApiProperty()
  signature: string;

  @ApiProperty()
  title: string;

  @ApiProperty()
  titleCertification: UserTitleCertification;

  @ApiProperty()
  name: string

  @ApiProperty()
  mobile: string;
}

class ArticleBase extends BaseResult {
  @ApiProperty()
  title: string;

  @ApiProperty()
  type: ArticleType;

  @ApiProperty()
  user: ArticleUser

  @ApiProperty()
  desc: string

  @ApiProperty()
  keywords: string[]

  @ApiProperty()
  publishTime: number

  @ApiProperty()
  thumbnails: string[]
}

export class ArticleShowNormalResult extends ArticleBase {
  @ApiProperty()
  ext: ArticleExt;
}


export class ArticleAdminIndexResult extends BaseAdminResult {
  @ApiProperty()
  title: string;

  @ApiProperty()
  thumbnails: string[];

  @ApiProperty()
  keywords: string[];

  @ApiProperty()
  status: ArticleStatus;

  @ApiProperty()
  desc: string;

  @ApiProperty()
  isStick: BooleanNumber;

  @ApiProperty()
  publishTime: number;

  @ApiProperty()
  user: ArticleUser;

  @ApiProperty()
  categories: ArticleNormalCategory[];

  @ApiProperty()
  type: ArticleType;
}

class ArticleAdminShowBase extends ArticleAdminIndexResult {
}

export class ArticleAdminShowNormal extends ArticleAdminShowBase {
  @ApiPropertyOptional()
  ext?: ArticleExt;
}


